package com.dddframework.core.context;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class BaseContext {
    private static Map<Object, Object> GLOBAL = new ConcurrentHashMap<>();

    /**
     * 显式注入
     *
     * @param key
     * @param value
     */
    public static void inject(Object key, Object value) {
        GLOBAL.put(key, value);
    }

    /**
     * 获取
     *
     * @param key
     * @param <T>
     * @return
     */
    public static <T> T get(Object key) {
        return (T) GLOBAL.get(key);
    }

    /**
     * 是否包含
     *
     * @param key
     * @return
     */
    public static boolean contains(Object key) {
        return GLOBAL.containsKey(key);
    }

}
